

const userInfoService = require('./../services/user-info')

module.exports = {

    async indexPage(ctx) {

        const title = 'register page'

        await ctx.render('register', {
            title,
            name: ctx.session.nickName || ''
        })

    },
    // register 注册
    async register(ctx) {

        let options = {
            name: ctx.request.body.name,
            pwd: ctx.request.body.pwd
        }
        let result  = await userInfoService.insertUser(options)
        
        if (result.serverStatus === 2) {
            ctx.session.nickName = ctx.request.body.name
        }
        
        ctx.redirect('/')

    }
} 